<template>
  <div class="dialog" :style="{ width: props.width }">
    <div class="title">
      <div class="presuffix" />
      {{ props.title }}
      <img :src="icons.closeIcon" @click="close" class="close">
    </div>
    <slot />
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import closeIcon from '@/assets/dialog/warn_close.svg'

const emit = defineEmits(['closeDialog'])
const icons = ref({
  closeIcon: closeIcon
})
const props = defineProps({
  title: {
    type: String,
    default: ''
  },
  width: {
    type: String,
    default: '50%'
  }
})

// 取消
// const handleCancel = () => {
//   if (dialog.value) {
//     dialog.value.visible = false
//   }
// }
const close = () => {
  emit('closeDialog')
}
</script>
<script lang="ts">
export default {
  inheritAttrs: false
}
</script>

<style lang="scss">
.dialog {
  border-radius: 5px;
  background: #1F2935;

  .title {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    color: #FFFFFF;
    font-size: 14px;
    background: #283442;

    .presuffix {
      width: 3px;
      height: 20px;
      border-radius: 0px 3px 3px 0px;
      background: #E6A23C;
      margin: 0 12px;
    }

    .close {
      width: 18px;
      height: 18px;
      margin-left: auto;
      margin-right: 12px;
      cursor: pointer;
    }
  }
}
</style>
